package com.jackiechan.day12;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

public class Test0_IO {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\ideaworkspace\\project02\\123.txt");
        System.out.println(file.length());
        System.out.println(file.getName());
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
        System.out.println(file.getParent());
        System.out.println(file.getAbsolutePath());
        System.out.println(file.exists());
        // 新建文件
        File file1 = new File("D:\\test\\2.txt");
        System.out.println(file1.createNewFile());
        System.out.println(file1.delete());
        // 新建文件夹
        File dir = new File("D:\\test1");
        System.out.println(dir.mkdir());
        System.out.println(dir.delete());
        // 递归新建文件夹
        File dirs = new File("D:\\Father\\Son");
        System.out.println(dirs.mkdirs());
        System.out.println(dirs.delete());
        System.out.println(dirs.delete());
        // list()
        File list = new File("D:\\ideaworkspace");
        // 列出文件夹下的文件
        String[] s = list.list();
        System.out.println(Arrays.toString(s));
        // 列出文件夹中的File对象
        File[] f = list.listFiles();
        System.out.println(Arrays.toString(f));
        System.out.println(f[1].length());
        System.out.println(Arrays.toString(f[1].listFiles()));
        System.out.println(f[1].listFiles()[1]);
    }
}
